<div class="panel">
	<p><b>Payment Plans</b></p>
</div>

<?=$system_message;?>

<?	/*
	$fn_att = array('name'=>'plan_name','value'=>set_value('plan_name'),'placeholder'=>'Payment Plan Name');
	
	if($payment_plan_values!==FALSE):
		foreach($payment_plan_values as $payment):
			$payment_plan_value[$payment['level_id'].'_'.$payment['payment_mode_id']] = $payment['payment_plan_amount'];
		endforeach;
	else:
		$payment_plan_value = FALSE;
	endif;
	
	if($fee_data!==FALSE):
		foreach($fee_data as $feedata):
			$f_data[$feedata->level_id] = $feedata->fee_rate;
		endforeach;
	else:
		$f_data = FALSE;
	endif;
?>

<div class="row">
	<div class="large-12 columns">
	<?php
	if(isset($system_message))echo $system_message;
	echo validation_errors() !==''?'<div data-alert class="alert-box alert">'.validation_errors().'<a href="#" class="close">&times;</a></div>' : NULL;
	?>
	<!--
		<?echo form_open('student_fees/payment_modes',"class='custom'");?>
		
		<div class="row collapse">
			<div class="small-2 columns">
			  <?php $attributes = array('class' => 'prefix radius');
				echo form_label('Payment Plan','payment_plan',$attributes);?>
			</div>
			<div class="small-10 columns">
			  <? echo form_input($fn_att); ?>
			</div>
		</div>
		<input type="submit" name="add_payment_plan" value="Add Payment Plan" class="btn btn-primary">
		</form>
	-->
	</div>
</div>

<div class="clearfix"></div>

<form action="<?=site_url('student_fees/payment_modes');?>" method="POST">
<table class="table table-striped table-hover">
	<thead>
		<tr>
			<td>Grade Level</td>
			<?php if($payment_plans !== FALSE){ foreach($payment_plans as $payment_plan): ?>
			<td style="text-transform:capitalize;"><?php echo $payment_plan['payment_mode_name']; ?> <!--<a href="#" data-dropdown="drop<?php echo $payment_plan['id']; ?>" class="btn btn-mini btn-inverse dropdown tiny"><i class="icon-g-more icon-g-white"></i></a>
				<ul id="drop<?php echo $payment_plan['id']; ?>" class="f-dropdown">
					<a href='<?php echo site_url("student_fees/edit_payment_mode/".$payment_plan['id']); ?>'>update</a>
					</br>
					<a href='<?php echo site_url("student_fees/delete_payment_mode/".$payment_plan['id']); ?>' class="confirm" title="Are You Sure?">delete</a>
				</ul>--></td>
			<?php endforeach; } ?>
		</tr>
	</thead>
	<tbody>
		<?php foreach($levels as $level): ?>
		<tr>
			<td><strong><?php echo $level->level_desc; ?></strong></td>
			<?php 
				if($payment_plans !== FALSE){ 
				foreach($payment_plans as $payment_plan): 
			?>
			<td><input name="<?php echo $level->level_id.'_'.$payment_plan['id']; ?>" value="<?php 
				if($payment_plan['id']==1){
					if($payment_plan_value===TRUE){
						if($payment_plan_value[$level->level_id.'_'.$payment_plan['id']] !== 0.00){ 
							echo $payment_plan_value[$level->level_id.'_'.$payment_plan['id']];
						}else{ 
							if ($f_data!==FALSE){ 
								var_dump($f_data[$level->level_id]); 
								if(empty($f_data[$level->level_id])){	
									echo '0.00';
								}else{
									echo $f_data[$level->level_id];
								} 
							}else{ 
								echo '0.00'; 
							} 
						}
					}else{
						if ($f_data!==FALSE){ 
							if(empty($f_data[$level->level_id])){
								echo '0.00';
							}else{
								echo $f_data[$level->level_id];
							} 
						}else{ 
							echo '0.00'; 
						} 
					}
				}else{
					echo $payment_plan_value===TRUE ? $payment_plan_value[$level->level_id.'_'.$payment_plan['id']]:'0.00'; 
				}
				?>" /></td>
			<?php 
				endforeach; 
				}
			?>
		</tr>
		<?php endforeach; ?>
		<?php if($payment_plans): ?>
		<tr><td colspan='<?php echo count($payment_plans)+1; ?>'><input type='submit' name='set_payment_plan' value='SUBMIT' class='btn btn-primary' /></td></tr>
		<?php endif; ?>
	</tbody>
</table>
</form>
*/?>

<?php if(!empty($payment_plans)):?>
	<div class="section-container auto" data-section data-options="deep_linking:true">
		<?php
			foreach($payment_plans as $payment_plan):
			$v = $payment_plan['payment_mode_name'];
			$var = $payment_plan['id'];
		?>
		<section>
		<p class="title" style="text-transform:capitalize;" data-section-title><a href="#<?=$v;?>"><?=$v;?></a></p>
		<div class="content" data-slug="<?=$v;?>" data-section-content>
			<?php $this->load->view('student_fees/template',array('data'=>$v,'data_id' =>$var,'levels' =>$levels,'ppv' =>$payment_plan_values)); ?>
		</div>
		</section>
		<?php endforeach; ?>
	</div>
<?else:?>
	<div class="alert alert-notice">
		<b>No Payment Modes Set</b>
	</div>
<?php endif; ?>

<?php
/*
if(!empty($available_levels)):?>
<div class="section-container auto" data-section data-options="deep_linking:true">

  <?foreach($available_levels as $k => $v):
	$var = $v.'_data';
  ?>
  <section>
    <p class="title" data-section-title><a href="#<?=$v;?>"><?=$v;?></a></p>
    <div class="content" data-slug="<?=$v;?>" data-section-content>
      <?$this->load->view('student_fees/template',array('data'=>$v,$v =>$var));?>
    </div>
  </section>
  <?endforeach;?>
</div>
<?else:?>
	<div class="alert alert-notice">
		<b>No Payment Modes Set</b>
	</div>
<?endif;
*/
?>
